home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / cpphtp2 / code.jar / code / ch11 / fig11_16.txt < prev    next >
Text File  |  1998-02-27  |  539b  |  22 lines

  1. 1   // Fig. 11.16: fig11_16.cpp 
  2. 2   // Using hex, oct, dec and setbase stream manipulators.
  3. 3   #include <iostream.h>
  4. 4   #include <iomanip.h>
  5. 5   
  6. 6   int main()
  7. 7   {
  8. 8      int n;
  9. 9   
  10. 10     cout << "Enter a decimal number: ";
  11. 11     cin >> n;
  12. 12  
  13. 13     cout << n << " in hexadecimal is: " 
  14. 14          << hex << n << '\n'
  15. 15          << dec << n << " in octal is: " 
  16. 16          << oct << n << '\n'
  17. 17          << setbase( 10 ) << n << " in decimal is: " 
  18. 18          << n << endl;
  19. 19  
  20. 20     return 0;
  21. 21  }
  22.